from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response
from rest_framework.pagination import PageNumberPagination


class CustomViewSet(ModelViewSet):
    def retrieve(self, request, *args, **kwargs):
        instance = self.get_object()
        data = instance.to_json
        return Response(data)


class MyPageNumberPagination(PageNumberPagination):
    page_size = 1
    page_query_param = "page"
    page_size_query_description = "size"
    max_page_size = 2